<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
	<head>
		<title>blog</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1" />
        <script src="/main/js/template-web.js"></script>
        <script src="/main/js/jquery.min.js"></script>
		<link rel="stylesheet" href="/layui/plugins/layui/css/layui.css" media="all" />
		<script src="/layui/plugins/layui/layui.js"></script>

		<link rel="stylesheet" href="/editmd/css/editormd.css" />
		<link rel="stylesheet" href="/editmd/css/editormd.preview.css" />

		<script src="/editmd/editormd.min.js"></script>

        <script src="/editmd/lib/marked.min.js"></script>
        <script src="/editmd/lib/prettify.min.js"></script>

		<script src="/editmd/lib/raphael.min.js"></script>
		<script src="/editmd/lib/underscore.min.js"></script>
		<script src="/editmd/lib/sequence-diagram.min.js"></script>
		<script src="/editmd/lib/flowchart.min.js"></script>
		<script src="/editmd/lib/jquery.flowchart.min.js"></script>
	</head>
	<body>
	<input type="hidden" th:value="${paper.id}" id="paperId" name="paperId"/>
	<div style="margin: 15px;">
		<fieldset class="layui-elem-field">
            <legend><button class="layui-btn layui-btn-danger layui-btn-radius" id="updateContent" name="updateContent">提交</button></legend>
			<div id="test-editormd2"> <textarea style="display:none;" th:text="${paper.content}"></textarea>  </div>
		</fieldset>
	</div>
        <div class="mini-posts">
                <script>
                    layui.use([ 'layer', 'element'], function(){
                        layer = layui.layer;//弹层
                        element = layui.element;//元素操作
                    });
                </script>


                <script type="text/javascript">
                            var testEditor2;
                            $(function() {
                                   testEditor2 = editormd("test-editormd2", {
                                       width: "90%",
                                       height: 640,
                                       path : '../editmd/lib/',
                                       imageUpload : true,
                                       imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                                       imageUploadURL : "/uploadFile",
                                       emoji : true,
                                       taskList : true,
                                       saveHTMLToTextarea : true
                                   });

                            });
                            $("#updateContent").bind('click', function(){
                                var newContent = testEditor2.getMarkdown();
                                var id = document.getElementById("paperId").value;
//                                alert(newContent+","+id);
                                $.ajax({
                                    url:"/paper/updateContent/"+id,    //请求的url地址
                                    dataType:"json",   //返回格式为json
                                    data:{"content":newContent},
                                    type:"GET",   //请求方式
                                    success:function (data) {
                                        if (data == '1'){
                                            layer.confirm('提交成功')
                                        }
                                        else {
                                            layer.confirm('出错啦')
                                        }
                                    }
                                })
                            });


                </script>
        </div>
	</body>
</html>